1 #include "ScreenTemplate.h"
3 #include "ScreenNames.h"
7 ScreenTemplate::ScreenTemplate()
12 std::cout
<< FPSDelay
<< "\n";
16 ScreenTemplate::~ScreenTemplate()
20 void ScreenTemplate::gameLoop() {
21 chrono::milliseconds ms
= chrono::duration_cast
<chrono::milliseconds
>(
22 chrono::system_clock::now().time_since_epoch());
25 long long initial
= 0;
26 long long expired
= 0;
29 ms
= chrono::duration_cast
<chrono::milliseconds
>(
30 chrono::system_clock::now().time_since_epoch());
38 while (expired
- initial
< FPSDelay
) {
39 ms
= chrono::duration_cast
<chrono::milliseconds
>(
40 chrono::system_clock::now().time_since_epoch());
48 void ScreenTemplate::processInput() {
50 while (SDL_PollEvent(&evnt
)) {
57 SDL_GetMouseState(&x
, &y
);
59 case SDL_MOUSEBUTTONDOWN
:
61 if (evnt
.button
.button
== SDL_BUTTON_LEFT
) {
70 case SDL_MOUSEBUTTONUP
:
72 mouseClickedL
= false;
73 mouseClickedR
= false;
78 bool ScreenTemplate::fadeIn(double durration
, SDL_Texture
* fadeTexture
) {
81 if (fadeRate
== 0) fadeRate
= 255 / (durration
/ (1 / FPSDelay
));
83 SDL_SetTextureAlphaMod(fadeTexture
, alpha
);
93 bool ScreenTemplate::fadeOut(double durration
, SDL_Texture
* fadeTexture
) {
96 if (fadeRate
== 0) fadeRate
= 255 / (durration
/ (1 / FPSDelay
));
98 SDL_SetTextureAlphaMod(fadeTexture
, alpha
);
108 //fadeOutDurration = milliseconds
109 void ScreenTemplate::fadeOutMusic(int fadeOutDuration
) {
110 rsc
->bptr
->fadeOutBGM(fadeOutDuration
);
114 void ScreenTemplate::update() {
116 void ScreenTemplate::play() {
118 void ScreenTemplate::render() {
120 void ScreenTemplate::close(){